<extend name="Public/base"/>

<block name="body">
    <div class="main-title">
        <h2>添加状态</h2>
    </div>
    <form action="{:U()}" id="commentForm" method="post"  class="form-horizontal" >
    <!-- 判断插入ID是否为空，如不为空隐藏插入ID值 -->
      <if condition="ACTION_NAME eq 'fdadd'">
        <label class="item-label">选择用户组<span class="check-tips">（设置用户组）</span></label>
        <div class="controls">
        <select name="auth_group" class="ywqx">
                <volist name="auth_groups" id="vo">     
                   <option value="{$vo.id|default=null}" <eq name="vo.id" value="$list['jb']"> selected</eq>>{$vo.title|default=null}</option>
                </volist>
        </select>
          <input type="hidden" class="text input-large" name="name" value="">
        </div>
        <else />
          <div class="form-item">
              <label class="item-label"> 
               名称<span class="check-tips"></span></label>
              <div class="controls">
                  <input type="text" class="text input-large" name="name" value="{$data.name}">
              </div>
          </div>
        </if>
        <div class="form-item">
            <label class="item-label">排序<span class="check-tips">(请输入排序数字，数字越小排名越靠前，仅限输入数字）</span></label>
            <div class="controls">
              <input type="text" class="text input-large" name="sid" value="">
            </div>
        </div>
       
        <div class="form-item">
            <label class="item-label">订单状态<span class="check-tips"></span></label>
            <div class="controls">
                <select name="ywstate">
                        <option value="1">开启</option>
                        <option value="0">禁用</option>
                      <volist name="authgroup" id="vo">     
                            <option value="{$vo.id|default=null}" <eq name="vo.id" value="$edit.jb_id"> selected</eq>>{$vo.title|default=null}</option>
                      </volist>
                </select>
            </div>

        </div>    
       <if condition="ACTION_NAME eq 'qdadd'"><input type="hidden" class="text input-large" name="lb" value="1">
            <elseif condition="ACTION_NAME eq 'ywadd'"/><input type="hidden" class="text input-large" name="lb" value="3">
            <elseif condition="ACTION_NAME eq 'lbadd'"/><input type="hidden" class="text input-large" name="lb" value="2">
            <elseif condition="ACTION_NAME eq 'zfkxadd'"/><input type="hidden" class="text input-large" name="lb" value="4">
			<elseif condition="ACTION_NAME eq 'zffsadd'"/><input type="hidden" class="text input-large" name="lb" value="5">
			<elseif condition="ACTION_NAME eq 'kzbqadd'"/><input type="hidden" class="text input-large" name="lb" value="6">
	</if>

        <div class="form-item">
            <button class="btn submit-btn" id="submit" type="submit"  target-form="form-horizontal">确 定</button>
            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
        </div>
    </form>

</block>

<block name="script">
    <script src="__STATIC__/thinkbox/jquery.validate.js"></script>
    <script src="__STATIC__/thinkbox/jquery.metadata.js"></script>
    <script src="__STATIC__/thinkbox/laydate.js"></script>
    <script >

    $().ready(function() {

         $("#commentForm").validate({

          rules: {
           name: { required:true
           },
           sid: {
            required: true,
            digits:true
           }
          },
          messages: {
               name: "请填写渠道名称",
               sid: {
                required: "请填写渠道顺序",
                digits: "请填写数字",
               }
            },
             submitHandler : function(form){
                $.ajax({
                    type: "POST",
                    url: "{:U('add')}",
                    data: $(form).serialize(),
                    success: function(msg){

                        $('.alert-content').html(msg.info);
                        $('#top-alert').addClass('alert-success').show();
                        setTimeout(function(){
                            location.href="{:U()}";
                        },1500); //延迟演示
                    },
                });
              $('#submit').attr("disabled","false");

             }

         });

          return false;   
        });
    </script>
     <script type="text/javascript">
        $('.ywqx').change(function(){
        //获取ywqx类别邻居属性并赋值。
        $(this).next().val($(this).find("option:selected").text());
        //查找当前选中选项中的TEXT文本并插入下级邻居表单中

        });
        //导航高亮
        <if condition="ACTION_NAME eq 'qdadd'">
        highlight_subnav('{:U('Ztgl/qdlb')}');
        <elseif condition="ACTION_NAME eq 'ywadd'"/>
        highlight_subnav('{:U('Ztgl/ywzt')}');
        <elseif condition="ACTION_NAME eq 'lbadd'"/>
        highlight_subnav('{:U('Ztgl/ywlb')}');
        <elseif condition="ACTION_NAME eq 'zfkxadd'"/>
        highlight_subnav('{:U('Ztgl/zfkx')}');
		<elseif condition="ACTION_NAME eq 'zffsadd'"/>
        highlight_subnav('{:U('Ztgl/zffs')}');
		<elseif condition="ACTION_NAME eq 'kzbqadd'"/>
        highlight_subnav('{:U('Ztgl/kzbq')}');		
        </if>
     </script>
</block>
